<?php
// 定义生肖数组
$zodiacs = [
    "鼠", "牛", "虎", "兔",
    "龙", "蛇", "马", "羊",
    "猴", "鸡", "狗", "猪"
];

// 定义生肖对冲关系
$opposites = [
    "鼠" => "马",
    "牛" => "羊",
    "虎" => "猴",
    "兔" => "鸡",
    "龙" => "狗",
    "蛇" => "猪",
    "马" => "鼠",
    "羊" => "牛",
    "猴" => "虎",
    "鸡" => "兔",
    "狗" => "龙",
    "猪" => "蛇"
];

// 处理查询请求
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["zodiac"])) {
    $selectedZodiac = $_POST["zodiac"];
    $oppositeZodiac = $opposites[$selectedZodiac];
}
?>

<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>生肖对冲查询游戏</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
            background-color: #f4f4f4;
        }

        h1 {
            color: #333;
        }

        form {
            margin-top: 20px;
        }

        select {
            padding: 8px;
            font-size: 16px;
        }

        button {
            padding: 10px 20px;
            font-size: 16px;
            background-color: #007BFF;
            color: white;
            border: none;
            cursor: pointer;
            border-radius: 5px;
        }

        button:hover {
            background-color: #0056b3;
        }

        #result {
            margin-top: 20px;
            font-size: 18px;
            color: #333;
        }
    </style>
</head>

<body>
    <h1>生肖对冲查询游戏</h1>
    <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
        <label for="zodiac">选择你的生肖:</label>
        <select id="zodiac" name="zodiac">
            <?php
            foreach ($zodiacs as $zodiac) {
                echo '<option value="' . $zodiac. '">' . $zodiac. '</option>';
            }
            ?>
        </select>
        <button type="submit">查询对冲生肖</button>
    </form>
    <?php
    if (isset($oppositeZodiac)) {
        echo '<div id="result">与 ' . $selectedZodiac. ' 对冲的生肖是：' . $oppositeZodiac. '</div>';
    }
    ?>
</body>

</html>